import axios from 'axios'
// 创建axios实例
const service = axios.create({
	baseURL: 'http://localhost:8085', // api的base_url
	timeout: 20000 // 请求超时时间
})

// http request 拦截器
// 每次请求都携带上token
service.interceptors.request.use(
	config => {
		//debugger
		if (localStorage.getItem('token')) {
			config.headers['token'] = localStorage.getItem('token');
		} else {
			config.headers['token'] = "";
		}
		return config
	},
	err => {
		return Promise.reject(err);
	}
)

export default service
